﻿using System;
using System.Collections.Generic;
using Volo.Abp.Domain.Entities.Auditing;

namespace YaAppoint.Appointments.Pools
{
    /// <summary>
    /// 实际号池
    /// </summary>
    public class Pool : FullAuditedEntity<Guid>
    {
        /// <summary>
        /// 名称 （只读）
        /// </summary>
        public virtual string Name
        {
            get
            {
                return $"{Device.Name}  {Date.ToString("MM月dd日")}：{StartTime.ToString("hh:mm")}-{EndTime.ToString("hh:mm")}";
            }
        }

        /// <summary>
        /// 当前预约数量
        /// </summary>
        public virtual int Current { get; set; } = 0;

        /// <summary>
        /// 号池类型
        /// </summary>
        public PoolType Type 
        {
            get 
            {
                return PlanPool != null ? PoolType.Pool : PoolType.SpecialPool;
            }
        }

        /// <summary>
        /// 开始时间
        /// </summary>
        public virtual DateTime StartTime { get; set; }

        /// <summary>
        /// 结束时间
        /// </summary>
        public virtual DateTime EndTime { get; set; }

        /// <summary>
        /// 日期
        /// </summary>
        public virtual DateTime Date { get; set; }

        /// <summary>
        /// 预约列表
        /// </summary>
        public virtual List<Appointment>? Appointments { get; set; }

        /// <summary>
        /// 号池计划
        /// </summary>
        public virtual PlanPool? PlanPool { get; set; }

        /// <summary>
        /// 号池计划ID
        /// </summary>
        public virtual Guid? PlanPoolId { get; set; }

        /// <summary>
        /// 特殊安排ID
        /// </summary>
        public virtual Guid? ScheduleOverrideId { get; set; }

        /// <summary>
        /// 检查设备ID
        /// </summary>
        public virtual Guid DeviceId { get; set; }

        /// <summary>
        /// 设备
        /// </summary>
        public virtual Device Device { get; set; }

        /// <summary>
        /// 上限人数
        /// </summary>
        public virtual int MaxCount { get; set; } = 10;

        /// <summary>
        /// 是否允许超限
        /// </summary>
        public virtual bool AllowOverFlow { get; set; }

        /// <summary>
        ///  活动
        /// </summary>
        public virtual bool IsActive { get; set; }
    }
}
